ci: lint JSON files using ESLint
authorYanase Yuki <[email protected]>
Tue, 3 Jun 2025 10:04:56 +0000 (19:04 +0900)
committerPaul Donald <[email protected]>
Sun, 8 Jun 2025 18:41:25 +0000 (20:41 +0200)
Add GitHub Actions CI which lints json files
using official ESLint json plugin.

Signed-off-by: Yanase Yuki <[email protected]>
.github/workflows/eslint.yml [new file with mode: 0644]
.gitignore
eslint.config.mjs [new file with mode: 0644]

diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml
new file mode 100644 (file)
index 0000000..3f0290e
--- /dev/null
@@ -0,0 +1,33 @@
+---
+name: "LuCI repo ESLint JSON Analysis"
+
+on:
+  push:
+    branches: [ "master" ]
+    path:
+      - '**/*.json'
+  pull_request:
+    branches: [ "master" ]
+    path:
+      - '**/*.json'
+permissions: {}
+
+jobs:
+  eslint:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Check out repository
+        uses: actions/checkout@v4
+
+      - name: Set up Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: latest
+
+      - name: Install ESLint
+        run: npm install --no-audit --no-fund --save-dev eslint@latest @eslint/json@latest
+
+      # Currently, we lint JSON only.
+      - name: Run ESLint
+        run: npx eslint **/*.json
+
index bfa495423f4d25a4e1c69a6052f05c4fee400ada..4e1d9051746f4758efdc8633793bc4fb91d87427 100644 (file)
@@ -17,4 +17,5 @@ modules/luci-compat/src/plural_formula.c
 modules/luci-compat/src/plural_formula.h
 docs/jsapi/*
 !docs/jsapi/README.md
-**eslint.config**
\ No newline at end of file
+**eslint.config**
+!eslint.config.mjs
diff --git a/eslint.config.mjs b/eslint.config.mjs
new file mode 100644 (file)
index 0000000..87f38a6
--- /dev/null
@@ -0,0 +1,13 @@
+import { defineConfig } from "eslint/config";
+import json from "@eslint/json";
+
+export default defineConfig([
+       {
+               files: ["**/*.json"],
+               ignores: ["package-lock.json"],
+               plugins: { json },
+               language: "json/json",
+               extends: ["json/recommended"],
+       },
+]);
+